package com.hotdog.aspect;

import com.alipay.api.domain.UserDetails;
import com.hotdog.feign.PayFeignClients;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
/**
 * 使用aop对支付页面进行日志记录
 * @author 郭鲁政
 */
@Slf4j
@Component
@Aspect
public class PayAspect {
    @Autowired
    private PayFeignClients payFeignClients;

    @Around("execution(* com.hotdog.service.PayUserService.getPayInfo(..))")
    public Object getInfo(ProceedingJoinPoint joinPoint) throws Throwable {
        String s = joinPoint.getArgs()[0].toString();
        log.debug(s);
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String name = authentication.getName();
        Object proceed = joinPoint.proceed();



        if (name == null) {
            return null;
        }
        payFeignClients.geturl(name,s);
        return proceed;
    }
}
